package com.wu.family.feed;

import com.wu.family.BaseActivity;
import com.wu.family.R;
import com.wu.family.config.UserInfo;
import com.wu.family.utils.WebViewUtil;
import com.wu.family.utils.WebViewUtil.OnWebLoadLintener;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.ImageButton;
import android.widget.TextView;

public class FeedDeitailBBSActivity extends BaseActivity implements OnClickListener{

	WebView webView;
	Context context;
	private ImageButton ibBbsBack, ibBbsRefresh, ibBbsGoBack, ibBbsForward;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.feed_detail_bbs_layout);
		webView = (WebView) findViewById(R.id.webView);
		context = this;
		WebViewUtil.config(context, webView, new OnWebLoadLintener() {
			@Override
			public void onReceivedTitle(String title) {}
			@Override
			public void onProgressChanged(int newProgress) {}
			@Override
			public void onPageStarted(String url) {
				showLoadingDialog();
			}
			@Override
			public void onPageFinished(String url) {
				hideLoadingDialog();
			}
			@Override
			public boolean onAppForwordUrl(String url) {
				return false;
			}
		});
		webView.loadUrl(getIntent().getStringExtra("url") + "&uid=" + UserInfo.getInstance(context).getUid());
		
		initView();
		initEvent();
	}

	private void initView() {
		ibBbsBack = (ImageButton) findViewById(R.id.ibBbsBack);
		ibBbsForward = (ImageButton) findViewById(R.id.ibBbsForward);
		ibBbsGoBack = (ImageButton) findViewById(R.id.ibBbsGoBack);
		ibBbsRefresh = (ImageButton) findViewById(R.id.ibBbsRefresh);
	}
	
	private void initEvent() {
		ibBbsBack.setOnClickListener(this);
		ibBbsForward.setOnClickListener(this);
		ibBbsGoBack.setOnClickListener(this);
		ibBbsRefresh.setOnClickListener(this);
	}
	
	@Override
	public void onClick(View v) {
		if (v == ibBbsBack) {
			finish();
		}else if (v == ibBbsForward) {
			webView.goForward();
		}else if (v == ibBbsGoBack) {
			webView.goBack();
		}else if (v == ibBbsRefresh) {
			webView.reload();
		}
	}

	
}
